﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class my_index : System.Web.UI.Page
{

    public string titletext;


    protected void Page_Load(object sender, EventArgs e)
    {

        if (Request["no"] == null)
        {
            if (Session["userno"] != null)
            {
                Response.Redirect("index.aspx?no=" + Session["userno"]);
            }
            else
            {
                ctp_lib.check_login(this.Page, null,false);
            }
        }


        ctpDataContext db = new ctpDataContext();
        int userno = int.Parse(Request["no"]);

        var data = from p in db.users
                   where p.no == userno
                   select p;

        user myuser = data.First();

        if (!this.IsPostBack)
        {
            
            titletext="My Citiport - "+myuser.nickname;

            this.HyperLink_add_city.Visible = false;
            this.HyperLink_edit.Visible = false;
            this.HyperLink_goto_my.Visible = false;
            this.LinkButton_login.Visible = false;
            this.Label_dot.Visible = false;
            


            if (Session["userno"] == null)
            {
                this.LinkButton_login.Visible = true;
            }
            else
            {
                if (userno == (int)Session["userno"])
                {
                    this.HyperLink_add_city.Visible = true;
                    this.HyperLink_edit.Visible = true;
                    this.Label_dot.Visible = true;
                }
                else
                {
                    this.HyperLink_goto_my.Visible= true;
                    this.HyperLink_goto_my.NavigateUrl = "index.aspx?no=" + Session["userno"].ToString();

                }
            }

        }



    }
    protected void LinkButton_login_Click(object sender, EventArgs e)
    {
        ctp_lib.check_login(this.Page, "my/index.aspx",false);
    }
}
